|
|
|
|
|
|
|
Testing the CURRENCY Data Type |
|
|
|
|
|
|
|
|
Copy the label and text box control again using the mouse to select the controls to be copied, and the Copy and Paste commands from the Edit menu. Change the label Caption property to Currency and the text box DataField property to CurrencyField. Refer to Figure 2.12 for spacing and sizing of the controls. |
|
|
|
|
|
|
|
|
Figure 2.12.
Adding the CURRENCY data type to the form. |
|
|
|
|
|
|
|
|
Save and run the program and test the CURRENCY data type text box. Press the Add button; enter the value 1.00001; force Visual Basic to save the value to the data table (press the Update button) and see what happens. Try entering 1.23456. When storing values to the CURRENCY data type field, Visual Basic stores only four places to the right of the decimal. If the number is larger than four decimal places to the right, Visual Basic rounds the value before storing it in the data field. Also, you notice that Visual Basic does not add a dollar sign ($) to the display of CURRENCY type data fields. |
|
|
|
|
|
|
|
|
Testing the DATETIME Data Type |
|
|
|
|
|
|
|
|
The Visual Basic DATETIME data type field is one of the most powerful data types. Visual Basic performs extensive edit checks on values entered in the DATETIME data type field. Using DATETIME data type fields can save a lot of coding when you need to make sure valid dates are entered by users. |
|
|
|
|
|
|
|
|
Create a new set of label and text box controls by copying the label and text box controls again. Change the label caption property to DateTime and the text box DataField property to DateTimeField. Your form should look like the one in Figure 2.13. |
|
|
|
|
|
|
|
|
Save and run the program. Try entering 12/32/95. As you can see, Visual Basic gives you an error message whenever you enter an invalid date. Now enter 1/1/0 into the Date text box. Notice that Visual Basic formats the date for you. |
|
|
|
|
|